package com.flexpasta.penneframework.remote
{
	import mx.rpc.events.ResultEvent;
	import mx.rpc.remoting.mxml.RemoteObject;

	/**
	 * Handles a remote object response
	 * @author Brian Telintelo 
	 */
	public dynamic class PenneRemoteObject extends RemoteObject implements IPenneObjectResult
	{
		private var resultFunction:Function;
		
		public function PenneRemoteObject(destination:String = null)
		{
			super(destination);
			this.addEventListener(ResultEvent.RESULT, internalResponse);
		}
		
		private function internalResponse(resultEvent:ResultEvent):void
		{
			resultFunction(resultEvent.result);
		}
		
		public function setResultFunction(result:Function):void
		{
			resultFunction = result;
		}
		
	}
}